package com.ostrich.cloud.ostrichOrderService.client;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ostrich.cloud.common.result.Result;
import com.ostrich.cloud.ostrichOrderService.client.param.*;
import com.ostrich.cloud.ostrichOrderService.model.dto.CustomerOrders;
import com.ostrich.cloud.ostrichOrderService.model.dto.GroupCustomerDto;
import com.ostrich.cloud.ostrichOrderService.model.dto.OrderAllGoods;
import com.ostrich.cloud.ostrichOrderService.model.dto.OrderDto;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;


/**
* name是项目名，contextId是client的名字
*/
@FeignClient(contextId = "orderManagerClient",name="ostrichOrderService")
public interface OrderManagerClient {

    //创建订单
    @PostMapping("create")
    @ApiOperation("创建订单")
    Result createOrder(@RequestBody CreateParam param) ;

    //查看订单
    @GetMapping("search")
    @ApiOperation("管理员查看订单")
    Result search(@RequestParam("orderNo") Long orderNo,@RequestParam("current") Integer current,@RequestParam("size") Integer size);

    //用户查看订单
    @GetMapping("customerSearch")
    @ApiOperation("用户查看订单")
    List<CustomerOrders> customerSearch();

    //修改订单状态
    @GetMapping("changeStatus")
    @ApiOperation("付钱")
    String changeOrderStatus(@RequestParam("orderNo") Long orderNo,@RequestParam("payType")Integer payType);

    //修改订单地址
    @PutMapping("changeLocation")
    @ApiOperation("修改订单地址")
    Result changeOrderLocationId(@RequestParam("orderNo") Long orderNo,@RequestParam("locationId") Integer locationId) ;

    //拼团订单
    @PostMapping("group")
    @ApiOperation("拼团订单")
    Result createGroup(@RequestBody AddGroupParam param);

    //秒杀订单
    @PostMapping("kill")
    @ApiOperation("秒杀订单")
    OrderDto createKill(@RequestBody AddKillParam param);

    //删除购物车详情表
    @DeleteMapping("delCar")
    @ApiOperation("删除购物车内容")
    Result delCar(@RequestParam("goodsId") int goodsId,@RequestParam("goodsNum") int goodsNum);

    //添加新物品进入购物车
    @PostMapping("addCar")
    @ApiOperation("加入购物车")
    Result addCar(@RequestBody AddGoodsCarParam param) ;

    //取消订单
    @PutMapping("calOrder")
    @ApiOperation("取消订单")
    Result calOrder(@RequestParam("orderNo")Long orderNo);

    //商家查询某段时间内订单
    @GetMapping("storeSearch")
    @ApiOperation("商家查询订单")
    Result storeOrderSearch(@RequestParam("current")Integer current,
                            @RequestParam("size")Integer size,
                            @RequestParam("startTime")@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
                            @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") Date startTime,
                            @RequestParam("finishTime")@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
                            @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") Date finishTime,
                            @RequestParam("businessmanId") Integer businessmanId,@RequestParam("orderNo") Long orderNo);

    //查看购物车物品
    @GetMapping("goods")
    @ApiOperation("查看购物车")
    Result searchGoods(@RequestParam("current")Integer current,@RequestParam("size")Integer size);

    //修改订单快递信息
    @PutMapping("delivery")
    @ApiOperation("修改快递信息")
    Result changeDelivery(@RequestParam("riderId")Integer riderId,@RequestParam("deliveryId")Integer deliveryId,@RequestParam("orderNo")Long orderNo);

    //修改订单状态
    @PutMapping("finish")
    @ApiOperation("自提完成订单")
    Result finishOrder(@RequestParam("orderNo")Long orderNo);

    //组团个人取消
    @PutMapping("cancelGroup")
    @ApiOperation("组团个人取消")
    Result cancelGroup(@RequestParam("orderNo") Long orderNo);

    //拼团到时取消
    @PutMapping("cancelAllGroup")
    @ApiOperation("拼团到时取消")
    Result cancelAllGroup(@RequestParam("groupbySn")Integer groupbySn);

    @GetMapping("orderInfo")
    @ApiOperation("订单详情")
    OrderAllGoods orderInfo(Long orderNo);

    //秒杀退单
    @PutMapping("cancelSec")
    @ApiOperation("秒杀退单")
    Result cancelSec(@RequestParam("orderNo") Long orderNo) throws Exception;

    //用户查所有订单
    @GetMapping("allOrder")
    @ApiOperation("用户查所有订单")
    Result userFindOrder(@RequestParam("current")Integer current,@RequestParam("size")Integer size);

    //组团顾客
    @GetMapping("groupCustomer")
    @ApiOperation("组团顾客")
    List<GroupCustomerDto> getGroupCustomer(@RequestParam("grouppbySn")Integer groupbySn);

    @GetMapping("test")
    Result getUrl();

}
